package com.whale.cloud.model;

import com.alibaba.fastjson.JSONObject;

import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/** Created by lide on 2017/6/5. */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class DataResponse {

  @ApiModelProperty(value = "唯一标识对应请求标识")
  private String id;

  @ApiModelProperty(value = "返回数据主体")
  private JSONObject data = new JSONObject();

  @ApiModelProperty(value = "反馈状态")
  private Status status;

  @ApiModelProperty(value = "返回消息")
  private String msg;

  @ApiModelProperty(value = "返回code")
  private String code=ResponseCode.FAILED;

  public DataResponse setCode(String code){
    this.code=code;
    return this;
  }

  public DataResponse setId(String id) {
    this.id = id;
    return this;
  }


  public DataResponse setData(JSONObject data) {
    this.data = data;
    return this;
  }

  public DataResponse setStatus(Status status) {
    this.status = status;
    return this;
  }

  public DataResponse setMsg(String msg) {
    this.msg = msg;
    return this;
  }

  public JSONObject toJSONObject() {
    JSONObject jsonObject = new JSONObject();
    jsonObject.put("id", this.getId());
    jsonObject.put("data", this.getData());
    jsonObject.put("status", this.getStatus());
    jsonObject.put("msg", this.getMsg());
    jsonObject.put("error_code", this.getCode());
    return jsonObject;
  }
}
